package com.tbm.prode.actions;

import java.util.logging.Logger;

import com.opensymphony.xwork2.ActionSupport;
import com.tbm.prode.model.Tournament;
import com.tbm.prode.model.User;
import com.tbm.prode.services.ProdeService;
import com.tbm.prode.services.TBMServiceFactory;
import com.tbm.prode.services.UserService;

public class Welcome extends ActionSupport{

	private static final long serialVersionUID = 1L;
	private static final Logger log = Logger.getLogger(Welcome.class.getName());
	
	private Tournament tournament;
	
	public String execute()	throws Exception {
		
		UserService userService = TBMServiceFactory.getUserService();
		User user = userService.getCurrentUser();
		
		ProdeService service = TBMServiceFactory.getProdeService();
		this.tournament = service.currentTournament();
		
		log.info("User logged: "+ user);
				
		if(user != null){
			return SUCCESS;
		}else{
			return INPUT;
		}
	}

	public Tournament getTournament() {
		return tournament;
	}

	public void setTournament(Tournament tournament) {
		this.tournament = tournament;
	}
	
	
	
}

